﻿Imports System.Windows.Forms

''' <summary>
''' Tooltip met een groter lettertype
''' </summary>
Public Class FairShopTooltip
    Inherits ToolTip

    Private Const FONT_NAME As String = "Tahoma"
    Private Const FONT_SIZE As Single = 12.0

    Public Sub New()
        MyBase.New()
        Me.OwnerDraw = True
    End Sub

    Public Sub New(ByVal Cont As System.ComponentModel.IContainer)
        MyBase.New(Cont)
        Me.OwnerDraw = True
    End Sub

    Private Sub Me_Popup(ByVal sender As Object, ByVal e As PopupEventArgs) Handles Me.Popup
        Dim f As New Font(FONT_NAME, FONT_SIZE + 0.1)
        Try
            e.ToolTipSize = TextRenderer.MeasureText( _
                Me.GetToolTip(e.AssociatedControl), f)
        Finally
            f.Dispose()
        End Try
    End Sub

    Private Sub Me_Draw(ByVal sender As Object, ByVal e As DrawToolTipEventArgs) Handles Me.Draw
        ' Draw the ToolTip with a larger font.

        e.DrawBackground()
        e.DrawBorder()

        ' Draw the custom text.
        Dim sf As StringFormat = New StringFormat
        Try
            'sf.Alignment = StringAlignment.Center
            'sf.LineAlignment = StringAlignment.Center
            'sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.None
            'sf.FormatFlags = StringFormatFlags.NoWrap

            Dim f As Font = New Font(FONT_NAME, FONT_SIZE)
            Try
                e.Graphics.DrawString(e.ToolTipText, f, _
                    SystemBrushes.WindowText, _
                    RectangleF.op_Implicit(e.Bounds), sf)
            Finally
                f.Dispose()
            End Try
        Finally
            sf.Dispose()
        End Try
    End Sub

End Class
